<template>
	<view class="wrap">
		<u-navbar :title="$t('index.apigl')" title-width="340" :border-bottom="false" back-icon-color="#fff" title-color="#fff" :background="{ backgroundColor: '#0030A8' }"></u-navbar>
		<view class="tom-container">
			<view class="api_block">
				<mescroll-uni  :fixed="false" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback">
					<view class="list" v-for="(item,index) in list" :key="index" @tap="toPay(item)">
						<view class="left">
							<image class="left_icon" :src="item.exchangeLogo"></image>
							<view class="left_text">{{item.exchangeName}}</view>
						</view>
						<view class="right" :class="{'bindSts':item.bindSts}">
							<view class="right_text">{{item.bindSts==1?$t('ybd'):$t('wbd')}}</view>
							<u-icon name="arrow-right" custom-prefix="custom-icon" size="50"></u-icon>
						</view>
					</view>
				</mescroll-uni>
			</view>
		</view>
	</view>
</template>

<script>
import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
import {mapState,mapGetters} from 'vuex';
export default {
	mixins: [MescrollMixin],
	data() {
		return {
			list:[],
			bindIP:'',
		};
	},
	methods: {
		toPay(item){
			uni.setStorageSync('bindIP', this.bindIP);
			this.$store.commit('saveShortData',item);
			uni.navigateTo({
				url: '/pages/User/apiManage/bingding/bingding'
			});
			
		},
		// 下拉刷新
		downCallback(){
			this.mescroll.resetUpScroll()
		},
		// 上拉加载
		upCallback(page){
			uni.showLoading({
				mask: true,
				title: this.$t('loading.title')
			});
			this.$api.userApi
				.getExchanges({
					qryCode:'api'
				})
				.then(res => {
					this.bindIP = res.data.bindIP;
					let list=res.data.exchangeList || [];
					this.mescroll.endSuccess(list.length)
					if(page.num == 1) this.list = []; //如果是第一页需手动制空列表
					this.list=this.list.concat(list); //追加新数据
					uni.hideLoading();
				}).catch(res =>{
					uni.hideLoading();
				})
		},
	}
};
</script>

<style lang="scss" scoped>
.tom-container {
	.api_block{
		flex: 1;
		background-color: #fff;
		margin: $nr-padd;
		border-radius: 20rpx;
		background-image: url('/static/new_images/showPopup.png');
		background-position: left bottom;
		background-repeat: no-repeat;
		background-size: 100% 800rpx;
		.list{
			display: flex;
			align-items: center;
			justify-content:space-between;
			border-bottom: 2rpx solid $page-bg;
			padding: 20rpx 10rpx 20rpx $nr-padd;
			.left{
				display: flex;
				align-items: center;
				color:$tom-text-color;
				.left_icon{
					width: 50rpx;height: 50rpx;
					margin-right: 20rpx;
				}
				.left_text{
					font-size: 28rpx;
				}
			}
			.right{
				display: flex;
				align-items: center;
				color:$tom-text-sub-color;
				.right_text{
					font-size: 28rpx;
				}
			}
			.bindSts{
				color: $tom-text-color;
			}
		}
	}
}
</style>
